/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ingenieriaeconomica;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;



/**
 *
 * @author Lisi
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */    
    private int n;
    public Pronosticos prono;
    public TMAR tmar;
    public Intereses interes;
    public Costos costos;
    public Escalonado escala;
    public Comisiones comision;
    public Servicios servicio;
    public Amortizacion amor;
    public Depreciacion depre;
    private DecimalFormat FD2 = new DecimalFormat("#######.##");
    public Principal() {        
        
        initComponents();        
    }    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla = new javax.swing.JTable();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        _bruto = new javax.swing.JCheckBox();
        _tmar = new javax.swing.JLabel();
        _costos = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        _escala = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        _costos1 = new javax.swing.JTextField();
        _costos2 = new javax.swing.JTextField();
        _costos3 = new javax.swing.JTextField();
        _costos4 = new javax.swing.JTextField();
        _costos5 = new javax.swing.JTextField();
        _costos6 = new javax.swing.JTextField();
        _costos7 = new javax.swing.JTextField();
        _costos8 = new javax.swing.JTextField();
        _costos9 = new javax.swing.JTextField();
        _costos10 = new javax.swing.JTextField();
        jButton11 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Modulos de Ingenieria Económica");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jButton1.setText("TMAR");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Pronosticos");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Costos");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Intereses");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Ingresos", null, null, null, null, null, null, null, null, null, null, null},
                {"Costos", null, null, null, null, null, null, null, null, null, null, null},
                {"Utilidad Bruta", null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {"", null, null, null, null, null, null, null, null, null, null, null},
                {null,  new Boolean(false), null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null},
                {"UAI", null, null, null, null, null, null, null, null, null, null, null},
                {"Debito Fiscal", null, null, null, null, null, null, null, null, null, null, null},
                {"Credito Fiscal", null, null, null, null, null, null, null, null, null, null, null},
                {"Iva por Pagar", null, null, null, null, null, null, null, null, null, null, null},
                {"Iva por Cobrar", null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Concepto", "IVA", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, true, true, true, true, true, true, true, false, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tabla);

        jButton5.setText("Pago Escalonado");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Comision (Ing)");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("Servicio (Cos)");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setText("Depreciación");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("Amortización");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        _bruto.setText("Bruto");
        _bruto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                _brutoActionPerformed(evt);
            }
        });

        _tmar.setText("24.35%");

        _costos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costosFocusLost(evt);
            }
        });

        jCheckBox1.setText("Individual");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Escala:");

        _costos1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos1FocusLost(evt);
            }
        });

        _costos2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos2FocusLost(evt);
            }
        });

        _costos3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos3FocusLost(evt);
            }
        });

        _costos4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos4FocusLost(evt);
            }
        });

        _costos5.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos5FocusLost(evt);
            }
        });

        _costos6.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos6FocusLost(evt);
            }
        });

        _costos7.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos7FocusLost(evt);
            }
        });

        _costos8.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos8FocusLost(evt);
            }
        });

        _costos9.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos9FocusLost(evt);
            }
        });

        _costos10.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                _costos10FocusLost(evt);
            }
        });

        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jButton10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jButton11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jButton1)
                                    .add(_tmar))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jButton2)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                        .add(_bruto)
                                        .add(16, 16, 16)))
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(_costos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(layout.createSequentialGroup()
                                        .add(jButton4)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(jButton5))
                                    .add(layout.createSequentialGroup()
                                        .add(jCheckBox1)
                                        .add(18, 18, 18)
                                        .add(jLabel2)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(_escala, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 75, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createSequentialGroup()
                                        .add(jButton6)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jButton8))
                                    .add(layout.createSequentialGroup()
                                        .add(jButton7)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jButton9))))
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 867, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .add(182, 182, 182)
                        .add(_costos1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(_costos10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(_costos9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(_costos8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2)
                    .add(jButton3)
                    .add(jButton4)
                    .add(jButton5)
                    .add(jButton6)
                    .add(jButton8))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(_bruto)
                    .add(_tmar)
                    .add(_costos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jCheckBox1)
                    .add(_escala, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2)
                    .add(jButton7)
                    .add(jButton9))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(_costos1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(_costos10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(4, 4, 4)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 476, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(167, 167, 167)
                .add(jButton11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jButton10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(86, 86, 86))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void LlenarTabla(Object dato, int col )
    {   
        tabla.setValueAt(dato, tabla.getSelectedRow(), col+1);        
    }
    
    public void LlenarTabla(Object dato, int col ,int fila)
    {   
        tabla.setValueAt(dato, fila, col+1);        
    }
    
    public void LlenarTmar(String dato)
    {   
        _tmar.setText(dato);
    }
    
    public Object JalarTabla(int fil, int col)
    {
        return tabla.getValueAt(fil,col+1);
    }
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        TMAR form=new TMAR();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);         
        tmar=form;
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        Pronosticos form=new Pronosticos();
        form.FormPri(this);
        form.setLocationRelativeTo(null);                
        form.setVisible(true);
        prono=form;
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        Costos form=new Costos();
        form.LlenarCostos(prono._y,prono.n);
        form.FormPri(this);
        form.setLocationRelativeTo(null);
        form.setVisible(true);
        costos=form;
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        Intereses form=new Intereses();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        interes=form;
    }//GEN-LAST:event_jButton4ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:        
    }//GEN-LAST:event_formWindowOpened

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        Escalonado form=new Escalonado();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        escala=form;
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        Comisiones form=new Comisiones();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        comision=form;
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:        
        Servicios form=new Servicios();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        servicio=form;
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        Depreciacion form=new Depreciacion();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        depre=form;
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        Amortizacion form=new Amortizacion();
        form.setLocationRelativeTo(null);
        form.FormPri(this);
        form.setVisible(true);
        amor=form;
    }//GEN-LAST:event_jButton9ActionPerformed

    private void Contar()
    {
        for(int i=3;i<23;i++)
        {
            if(tabla.getValueAt(i, 1)==null)
            {
                n=i;
                break;
            }
        }
    }
    
    private void Formato(double var,int dec)
    {
        BigDecimal bD;
        String temporal;
        temporal= var+"";
        bD= new BigDecimal(temporal);
        //System.out.println(.setScale(dec, RoundingMode.HALF_UP));
        
    }
    
    public boolean EsBruto()
    {
        if(_bruto.isSelected())
        {
            return true;
        }
        return false;
    }
    
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        Contar();
        double Suma;
        double conFac;
        double anterior=0.0;
        double iva;
        double poriva=.12;
        if(_bruto.isSelected())
        {
            poriva=(.12/1.12);
        }
        for(int i=0;i<10;i++)
        {
            conFac=0;
            for(int l=0;l<n;l++)
            {                
                if(tabla.getValueAt(l,11)==true)
                {
                    conFac+=Double.parseDouble(tabla.getValueAt(l,i+1).toString());
                }
            }
            Suma=0;
            for(int j=3;j<n;j++)
            {
                Suma+=Double.parseDouble(tabla.getValueAt(j,i+1).toString());
            }
            tabla.setValueAt(FD2.format(Double.parseDouble(tabla.getValueAt(2,i+1).toString())-Suma),23,i+1);
            tabla.setValueAt(FD2.format(Double.parseDouble(tabla.getValueAt(0,i+1).toString())*poriva),24,i+1);
            tabla.setValueAt(FD2.format(conFac*poriva),25,i+1);
            iva=((Double.parseDouble(tabla.getValueAt(0,i+1).toString())*poriva)-(conFac*poriva))+anterior;
            anterior=iva;
            if(iva>-1)
            {
                tabla.setValueAt(FD2.format(iva),26,i+1);
                anterior=0;
                tabla.setValueAt(FD2.format(anterior),27,i+1);
            }
            else
            {
                tabla.setValueAt(FD2.format(0.0),26,i+1);
                tabla.setValueAt(FD2.format(anterior*-1),27,i+1);
            }
            
            
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void _brutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__brutoActionPerformed
        // TODO add your handling code here:
        double poriva=1;
        if(EsBruto())
        {
            poriva=(1/1.12);
        }
        else            
        {
            poriva=1.12;
        }
        for(int i=0; i<10;i++)
        {
            LlenarTabla(FD2.format(Double.parseDouble(JalarTabla(0,i+1).toString())*poriva), i+1,0);            
        }
        /*
                princi.LlenarTabla(FD2.format(_ls[i]*poriva), i+1);
            }            
        }
        else
        {
            for(int i=0;i<10;i++)
            {
                princi.LlenarTabla(FD2.format(_li[i]*poriva), i+1);
            }
        }*/
    }//GEN-LAST:event__brutoActionPerformed

    private void _costosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costosFocusLost
        // TODO add your handling code here:
        for(int i=0; i<10;i++)
        {
            LlenarTabla(FD2.format(Double.parseDouble(_costos.getText())/100*Double.parseDouble(JalarTabla(0,i+1).toString())), i+1,1);
            LlenarTabla(FD2.format(Double.parseDouble(JalarTabla(0, i+1).toString())-Double.parseDouble(JalarTabla(1, i+1).toString())), i+1,2);
        }
        _costos1.setText(_costos.getText());
        _costos2.setText(_costos.getText());
        _costos3.setText(_costos.getText());
        _costos4.setText(_costos.getText());
        _costos5.setText(_costos.getText());
        _costos6.setText(_costos.getText());
        _costos7.setText(_costos.getText());
        _costos8.setText(_costos.getText());
        _costos9.setText(_costos.getText());
        _costos10.setText(_costos.getText());
        
    }//GEN-LAST:event__costosFocusLost

    private void _costos1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos1FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos1FocusLost

    private void _costos2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos2FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos2FocusLost

    private void _costos3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos3FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos3FocusLost

    private void _costos4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos4FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos4FocusLost

    private void _costos5FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos5FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos5FocusLost

    private void _costos6FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos6FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos6FocusLost

    private void _costos7FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos7FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos7FocusLost

    private void _costos8FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos8FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos8FocusLost

    private void _costos9FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos9FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos9FocusLost

    private void _costos10FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event__costos10FocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event__costos10FocusLost

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        for(int i=0; i<10;i++)
        {
           this.LlenarTabla(FD2.format(Double.parseDouble(this.JalarTabla(0, i+1).toString())-Double.parseDouble(this.JalarTabla(1, i+1).toString())), i+1,2);
        } 
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
               new Principal().setVisible(true);                
            }
        });
    }   
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox _bruto;
    private javax.swing.JTextField _costos;
    private javax.swing.JTextField _costos1;
    private javax.swing.JTextField _costos10;
    private javax.swing.JTextField _costos2;
    private javax.swing.JTextField _costos3;
    private javax.swing.JTextField _costos4;
    private javax.swing.JTextField _costos5;
    private javax.swing.JTextField _costos6;
    private javax.swing.JTextField _costos7;
    private javax.swing.JTextField _costos8;
    private javax.swing.JTextField _costos9;
    private javax.swing.JTextField _escala;
    private javax.swing.JLabel _tmar;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabla;
    // End of variables declaration//GEN-END:variables
}
